package DataFile;

import java.nio.ByteBuffer;
import java.util.Formatter;

import ClassData.ConstantPoolFloat_Info;

public class Structure_CP_FloatInfo extends Structure_CP_Constant {

	ConstantPoolFloat_Info myFloatInfo;
	
	public Structure_CP_FloatInfo(ConstantPoolFloat_Info myFloatInfo) {
		this.myFloatInfo=myFloatInfo;
	}

	public int getMemorySize() {
		int size;
		
		size =BYTE_WIDTH;	// Type
		size+=FLOAT_WIDTH;	// class name index
	
		return(size);	
	}

	protected String getMemoryMapAsString() {
		String returnString;
		
		returnString=getAdressAsHexString(baseAdress);
		returnString+=" : (float info) : size - "+new Formatter().format("%3d",getMemorySize());
		returnString+=" Value : "+myFloatInfo.getValue()+"\n";
		
		return(returnString);
	}

	/**
	 *  writes data into memory file
	 *  
	 *  @author Tavin
	 *  
	 *  @param fileData buffer for data 
	 */
	
	public void writeData(ByteBuffer fileData) {
		fileData.position(baseAdress-DataFileCreator.BASE_MEMORY_ADRESS);
		fileData.put((byte)myFloatInfo.getType());
		fileData.putFloat(myFloatInfo.getValue());
	}

}
